{extend name="common:base" /}

{block name="main"}
<!--body wrapper start-->
<div class="wrapper">
    <div class="row">
        <div class="col-md-12">
            <!--breadcrumbs start -->
            <ul class="breadcrumb panel">
                <li><a href="{:url('Index/index')}"><i class="fa fa-home"></i> 控制台</a></li>
                <li><a href="{:url('index')}">文章管理</a></li>
                <li class="active">文章分类</li>
            </ul>
            <!--breadcrumbs end -->
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel">
                <header class="panel-heading col-xs-12 ">
                        <div class="form-group">
                            <a href="#"  class="btn btn-success ajax-get" onclick="recharge();" title="添加分类">添加分类</a>
                        </div>

                </header>
                <div class="panel-body">
                    <form class="ids" action="" method="post">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>分类ID</th>
                                <th>名称</th>
                                <th>分类文章</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='data' id='v'}
                            <tr>
                                <td>{$v.id}</td>
                                <td><input type="text"  value="{$v.name}" id="open0_{$v['id']}">  <a href="#"  class="btn btn-success ajax-get" onclick="do_bao({$v['id']})" title="保存">保存</a>&nbsp;&nbsp;</td>
                                <td> <a href="{:url('article/article_list',['cate'=>$v['id']])}"title="分类文章">分类文章</a></td>
                                <td>
                                    <a href="{:url('article/cate_del',['id'=>$v['id']])}" class="fa fa-times confirm " onclick="return confirm('确定该分类下的文章已经全部删除?');" title="删除"></a>
                                </td>
                            </tr>
                            {/volist}

                            </tbody>
                        </table>
                    </form>

                </div>
            </section>
        </div>

    </div>
</div>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="rechargeModal" class="modal fade">
    <div class="modal-dialog" style="width:400px;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">添加分类</h4>
            </div>
            <form class="form-horizontal form-post-addmoney" action="{:url('add_cate')}" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-lg-3 col-sm-3 control-label">分类名称</label>
                        <div class="col-lg-8">
                           <input type="text" class="form-control" name="name" value="">
                        </div>
                    </div>
                <div class="modal-footer">
                    <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                    <button class="btn btn-primary " type="submit" target-form="form-post-addmoney">提交</button>
                </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="__JS__/layer/layer.js"></script>
<script type="text/javascript">
    function recharge() {
        $('#rechargeModal').modal('show');
    }
    function do_bao(id) {
        var dateline0 = 'open0_'+id;
        var name =document.getElementById(dateline0).value;
        $.ajax({
            type: "post",
            url: "{:url('article/do_bao')}",
            data: {'name':name,'id':id},
            dataType: "json",
            async: false,
            success: function(data) {
                var msg = data.msg;
                layer.msg(msg,{icon:6,time:1000});
                setTimeout(function(){
                    location.reload()},1000
                );
            }
        });
    }
</script>
<!--body wrapper end-->
{/block}
